package com.ugrow.Study_System.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ListView;

import com.ugrow.Study_System.R;

import java.net.Inet4Address;
import java.util.HashMap;

public class HomeActivity extends AppCompatActivity {
    private  String[] itemName = new String[]{"定时器","BaseAdapter", "GridView","Dialog","广播接收者"
                ,"帧动画","补间动画","属性动画"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

        ArrayAdapter<String> adpter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,itemName);
        ListView contentLv = (ListView) findViewById(R.id.act_home_content_lv);
        contentLv.setAdapter(adpter);

        //ListView设置条目点击时间
        contentLv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                startOnActivity(i);

            }
        });

    }




    /**
     * 点击条目时,跳转到相应页面
     * */
    private void startOnActivity(int i) {
        switch (i){
            case 0:
                Intent intent = new Intent(HomeActivity.this,TimerActivity.class);
                startActivity(intent);
                break;
            case 1:
                Intent intent1 = new Intent(HomeActivity.this,BaseAdapterActivity.class);
                startActivity(intent1);
                break;
            case 2:
                Intent intent2 = new Intent(HomeActivity.this,GirdViewActivity.class);
                startActivity(intent2);
                break;
            case 3:
                Intent intent3 = new Intent(HomeActivity.this, DialogActivity.class);
                startActivity(intent3);
                break;
            case 5:
                Intent intent4 = new Intent(HomeActivity.this, FrameAnimActivity.class);
                startActivity(intent4);
                break;
            case 6:
                Intent intent5 = new Intent(HomeActivity.this, MendAnimActivity.class);
                startActivity(intent5);
                break;
            case 7:
                Intent intent6 = new Intent(HomeActivity.this, PropertyAnimActivity.class);
                startActivity(intent6);
            default:
        }
    }
}
